<?php
/**
 * Created by PhpStorm.
 * User: hgq
 * Date: 16/3/14
 * Time: 下午2:20
 */
use \yii\helpers\Url;

$web = Url::to('@web');
?>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta content="telephone=no" name="format-detection">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="no">
    <title>订单确认</title>
    <link type="text/css" href="<?= $web ?>/css/wx-good/global.css" rel="stylesheet"/>
    <link type="text/css" href="<?= $web ?>/css/wx-good/order-form.css" rel="stylesheet"/>

    <script type="text/javascript" src="<?= $web ?>/js/jquery.js"></script>
    <script type="text/javascript" src="<?= $web ?>/js/tools.js?1"></script>

    <?php     require_once Yii::$app->viewPath.'/wx-no-share.php'  ?>

    <?php     require_once Yii::$app->viewPath.'/wx-calc-price.php'  ?>

    <script type="text/javascript">


        $(document).ready(function () {
            var w = $(document).width();
            if (w > 640) {
                w = 640;
            }
            $("html").css("font-size", w * 20 / 320);

        });

        $(function ($) {
            //init
            var address=<?=$address ? json_encode($address) : 0?>;

            if(address!=0){
                $(".head-null").css("display", "none")
                $(".null-img").css("display", "none")
                $(".head-user").css("display", "block")
                $(".user-address").css("display", "block")
                $(".head-img").css("display", "block")
            } else {
                $(".head-null").css("display", "block")
                $(".null-img").css("display", "block")
                $(".head-user").css("display", "none")
                $(".user-address").css("display", "none")
                $(".head-img").css("display", "none")
            }
        });

        $order_type = <?=json_encode($order_type)?>;
        $goods_code = '';
        $order_goods_List = <?=json_encode($order_goods_List)?>;
        if ($order_goods_List !== null && $order_goods_List.length > 0) {
            $goods_code = $order_goods_List[0]['GOODS_CODE'];
        }

        function edit_address() {
            window.location.href='<?=Url::to(['wx-home/address-management','backurl'=>Yii::$app->request->absoluteUrl])?>';
        }

        function submit_order() {
            var isAddress = $(".head-null").is(":hidden");
            if(!isAddress){
                alert('请先填写收货信息');
                return;
            }
            var data = {};
            //order_type = 1 代表从购物车下的订单  =2 代表单个产品快捷下单
            data.order_type = $order_type;
            data.goods_code = null;
            data.coin = $('#txt_duola_coin').val();
            if (data.order_type == 2) {
                data.goods_code = $goods_code;
            } else {
                data.goods_code = '';
            }
            var re = requestJson("<?=Url::to(['wx-good/order-form-handle'])?>", data);
            if (re.status == 0) {
                //跳转至订单列表
                window.location.href = "<?=Url::to(["wx-good/order-detail"]);?>?order_id=" + re.data.order_id;
            } else {
                alert(re.message);
            }
        }

    </script>
</head>
<body>
<div class="main" style="width: 16rem; margin: 0 auto;">
    <div class="head-head-top"></div>
    <div class="head" onclick="edit_address();">
        <div class="head-border">
            <img src="<?= $web ?>/img/wx-good/order-1.png" style="width: 100%">
        </div>
        <div class="head-null">
            <div class="user-people-null">
                <div class="user-people-img">
                    <img src="<?= $web ?>/img/wx-good/order-3.png" style="height: 100%">
                </div>
                <div class="user-people-name">
                    <span>未填写收货信息</span>
                </div>
            </div>
        </div>
        <div class="head-user">
            <div class="user-people">
                <div class="user-people-img">
                    <img src="<?= $web ?>/img/wx-good/order-3.png" style="height: 100%">
                </div>
                <div class="user-people-name">
                    <span><?php if ($address == null) {
                            echo '';
                        } else {
                            echo $address['NAME'];
                        } ?></span>
                </div>
            </div>
            <div class="user-phone">
                <div class="user-phone-img">
                    <img src="<?= $web ?>/img/wx-good/order-4.png" style="height: 100%">
                </div>
                <div class="user-phone-number">
                    <span><?php if ($address == null) {
                            echo "";
                        } else {
                            echo $address['PHONE'];
                        } ?></span>
                </div>
            </div>
        </div>
        <div class="user-address">
            <span><?php if ($address==false) {
                    echo "";
                } else {
                    echo $address['PROVINCE'] . $address['CITY'] . $address['REGION'] . $address['ADDRESS'];
                } ?></span>
        </div>
        <div class="head-img">
            <img src="<?= $web ?>/img/wx-good/order-2.png" style="width: 0.5rem">
        </div>
        <div class="null-img">
            <img src="<?= $web ?>/img/wx-good/order-2.png" style="width: 0.5rem">
        </div>
    </div>

    <?php
    foreach ($order_goods_List as &$order_goods) {
        ?>
        <div class="commodity">
            <div class="commodity-img">
                <img src="<?= $order_goods['IMAGE_URL'] ?>" style="width: 3rem; height: 3rem;">
            </div>
            <div class="commodity-details">
                <div class="commodity-name">
                    <?= $order_goods['GOODS_NAME'] ?>
                </div>
                <div class="commodity-integral">
                    单价&nbsp;&nbsp;&nbsp;&nbsp;<span><?= $order_goods['PRICE'] ?></span>
                </div>
                <div class="commodity-number">
                    数量&nbsp;&nbsp;&nbsp;&nbsp;<span class="span-x">x</span><span
                        class="span-number"><?= $order_goods['COUNT'] ?></span>
                </div>
            </div>
        </div>
        <?php
    }
    ?>
    <div class="price">
        <div class="price-div price-top">
            <div class="price-left">运费</div>
            <div class="price-right">0.00</div>
        </div>
        <div class="price-div price-bottom">
            <div class="price-left">总价</div>
            <div class="price-right"><?= $TOTALPRICE ?></div>
        </div>
    </div>
    <div class="payment">
        <div class="payment-top">
            您共有&nbsp;<span><?= $user_info['DORACOIN_ACCOUNT'] ?></span>&nbsp;朵拉币可用于支付
        </div>
        <div class="payment-bottom">
            <div class="pay-integral">
                <div class="pay-left" style="width: 10em;">
                    需要支付的朵拉币
                </div>
                <div class="pay-right" style="float: left;">
                    <input id="txt_duola_coin" type="tel" class="font3" style="width:10em;height:100%; border: 1px solid #ccc;padding-left: 0.1rem"
                           value="0"
                           oninput="checkNumVal_int(this);calc_coin(this.value);">
                </div>
            </div>
            <div class="pay-money">
                <div class="pay-money-left" style="width: 10em;">
                    需要支付的现金
                </div>
                <div class="pay-money-right" style="float: left;width:10em;">
                    ￥<span id="realPrice_dom">0</span>
                </div>
            </div>
        </div>
    </div>
    <div class="foot" onclick="submit_order();">订单确认</div>
    <div class="foot-bottom"></div>
</div>
</body>
</html>
